using Microsoft.AspNetCore.Mvc;
using JTZY.Model.System.Dto;
using JTZY.Model.System;
using JTZY.Service.System.ISystemService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2025-01-21
namespace JTZY.Admin.WebApi.Controllers.System
{
    /// <summary>
    /// 店铺设置表
    /// </summary>
    [Verify]
    [Route("system/Corecmssetting")]
    public class CorecmssettingController : BaseController
    {
        /// <summary>
        /// 店铺设置表接口
        /// </summary>
        private readonly ICorecmssettingService _CorecmssettingService;

        public CorecmssettingController(ICorecmssettingService CorecmssettingService)
        {
            _CorecmssettingService = CorecmssettingService;
        }

        /// <summary>
        /// 查询店铺设置表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmssetting:list")]
        public IActionResult QueryCorecmssetting([FromQuery] CorecmssettingQueryDto parm)
        {
            var response = _CorecmssettingService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询店铺设置表详情
        /// </summary>
        /// <param name="SKey"></param>
        /// <returns></returns>
        [HttpGet("{SKey}")]
        [ActionPermissionFilter(Permission = "corecmssetting:query")]
        public IActionResult GetCorecmssetting(string SKey)
        {
            var response = _CorecmssettingService.GetInfo(SKey);
            
            var info = response.Adapt<CorecmssettingDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加店铺设置表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmssetting:add")]
        [Log(Title = "店铺设置表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmssetting([FromBody] CorecmssettingDto parm)
        {
            var modal = parm.Adapt<Corecmssetting>().ToCreate(HttpContext);

            var response = _CorecmssettingService.AddCorecmssetting(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新店铺设置表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmssetting:edit")]
        [Log(Title = "店铺设置表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmssetting([FromBody] CorecmssettingDto parm)
        {
            var modal = parm.Adapt<Corecmssetting>().ToUpdate(HttpContext);
            var response = _CorecmssettingService.UpdateCorecmssetting(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除店铺设置表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmssetting:delete")]
        [Log(Title = "店铺设置表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmssetting([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<string>(ids);

            return ToResponse(_CorecmssettingService.Delete(idArr));
        }

    }
}